<?php namespace App\Filters;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;

class BotFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        $at_obj = $request->header('Authorization');
        if (!$at_obj) exit('Invalid access token');
        $access_token = $at_obj->getValue();
        $access_token_ = accessToken_decode($access_token);
        if ($access_token_[0] === true) {
            if ($access_token_[2] + 10 < time()) exit('Access token expired');
            return $request;
        }
        exit('Invalid access token');
    }

    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
    {


    }
}